//
//  HBHChouseTypeView.m
//  HubeiHotel
//
//  Created by 张露杰 on 17/11/16.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "HBHChouseTypeView.h"

typedef void(^HBHChouseTypeBlock)(NSString *);

@implementation HBHChouseTypeView
{
  
    HBHChouseTypeBlock _complete;

}
- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title complete:(void(^)(NSString *title))complete
{
    self = [super initWithFrame:frame];
    if (self) {
        if (complete) {
            _complete = complete;
        }
        self.frame = CGRectMake(frame.origin.x, frame.origin.y, SCREENW/3, 41*screenW_6);
        
        _title = title;
        UILabel *label = [TomamaUI createLabel:CGRectMake(0, 0, [TomamaUI getStringWeithtWith:title andHeigth:14*screenW_6 andFont:[UIFont systemFontOfSize:14*screenW_6]], 14*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:14*screenW_6] textColor:TextBlack text:title];
        [self addSubview:label];
        label.center = CGPointMake((self.frame.size.width - 16.5*screenW_6)/2, self.frame.size.height/2);
        
        _icon = [TomamaUI createImageView:CGRectMake(CGRectGetMaxX(label.frame) + 9*screenW_6, 0, 7.5*screenW_6, 4.5*screenW_6) backGroundImageV:@"Main_search_down"];
        [self addSubview:_icon];
        _icon.center = CGPointMake(_icon.center.x, label.center.y);
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(click)];
        [self addGestureRecognizer:tap];
    }
    return self;
}

-(void)click
{
    _icon.image = [UIImage imageNamed:@"Main_search_up"];
    _complete(_title);
}

@end
